package edu.sctu.zhuyingzhi.month201506.day20150619.subwayProjectV1;

/**
 * Created by user13 on 2015/5/31.
 */
public class CardReader {

     MetroStation metroStation = new MetroStation();

    /**
     * price为价格
     * number为站数
     * @param judge
     * @param subwayCard
     */
     public void IntoSubway(String judge,SubwayCard subwayCard) throws InterruptedException {
        if(judge.equals("有卡")){
            System.out.println("你的票是蓉城卡");
            System.out.println("请刷卡");
        }
         else{
            System.out.println("你的票是单程票");

            System.out.println("请刷卡");
            Thread.sleep(1000);
            System.out.println("你所出发的站是："+subwayCard.inStation+"\t要到达的站是："+subwayCard.outStation);

        }

     }

    public void ComeOutSubway(String judge,SubwayCard subwayCard) throws InterruptedException {
        System.out.print("车辆行驶中");
        for (int i = 0; i < 10; i++) {
            System.out.print(".");
            Thread.sleep(1000);
        }

        System.out.println("到站了");

        if(judge.equals("有卡")){
            float  balance= subwayCard.Balance;
            int number = Math.abs(metroStation.MetroStation().get(subwayCard.inStation)-metroStation.MetroStation().get(subwayCard.outStation));
            switch(number){
                case 1:
                case 2:
                case 3:
                    System.out.println(subwayCard.inStation+"到"+subwayCard.outStation+"需要2元 请支付：");balance = balance-2;break;
                case 4:
                case 5:
                case 6:
                    System.out.println(subwayCard.inStation+"到"+subwayCard.outStation+"需要4元 请支付：");balance = balance-4;break;
                case 7:
                case 8:
                    System.out.println(subwayCard.inStation+"到"+subwayCard.outStation+"需要5元 请支付：");balance = balance-5;break;
                default:
                    System.out.println(subwayCard.inStation+"到"+subwayCard.outStation+"需要6元 请支付：");balance = balance-6;break;
            }
            Thread.sleep(3000);
            System.out.println("支付完成");
            System.out.println("余额为"+balance);
        }
        
        else{
            System.out.println(" 请把卡片投入回收器里面回收");
        }
    }
}
